Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
Have this code so when a user presses the up or down key the balloon grows or shrinks. Need balloon to burst to "💥" when it reaches font size over 70

So far the balloon should only be able to reach max 70 font before it bursts. I need to turn the balloon into "💥". The event listener needs to be removed when the balloon bursts.

let para = document.querySelector('p');
para.style.fontSize = '24px';

window.addEventListener("keydown", e => {
  var sizeAsInteger = parseInt(para.style.fontSize, 10);

  if (e.key == "ArrowUp") {
    sizeAsInteger += 10;
  } else {
    sizeAsInteger -= 10;
  }

  para.style.fontSize = sizeAsInteger + 'px';
});
p {
  font-size: 50px;
}
<body>
  <p>🎈</p>
</body>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Is this what you want?

let para = document.querySelector("p");

para.style.fontSize = "24px";

const increaseSize = e => {
  var sizeAsInteger = parseInt(para.style.fontSize, 10);

  if (sizeAsInteger >= 70) {
    window.removeEventListener("keydown", increaseSize);
    return (para.innerHTML = "💥");
  }

  if (e.key == "ArrowUp") {
    sizeAsInteger += 10;
  } else {
    sizeAsInteger -= 10;
  }

  para.style.fontSize = sizeAsInteger + "px";
};

window.addEventListener("keydown", increaseSize);
p {
  font-size: 50px;
}
<p>🎈</p>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda